<!DOCTYPE html>
<html>
<head><meta name="generator" content="Hexo 3.8.0">
    

    

    



    <meta charset="utf-8">
    
    
    
    
    <title>js-深入-new模拟实现 | lafen | lafen&#39;s personal blog</title>
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    
    <meta name="theme-color" content="#3F51B5">
    
    
    <meta name="keywords" content="note,js">
    <meta name="description" content="new 的模拟实现new 操作符的使用12345678910111213141516// 构造函数function Person(name, age) &amp;#123;    this.name = name    this.age = age&amp;#125;// 原型对象上的属性Person.prototype.intro = function() &amp;#123;    console.log(`i am">
<meta name="keywords" content="note,js">
<meta property="og:type" content="article">
<meta property="og:title" content="js-深入-new模拟实现">
<meta property="og:url" content="https://lafen.gitee.io/2019/11/23/js-深入-new模拟实现/js-深入-new模拟实现/index.html">
<meta property="og:site_name" content="lafen">
<meta property="og:description" content="new 的模拟实现new 操作符的使用12345678910111213141516// 构造函数function Person(name, age) &amp;#123;    this.name = name    this.age = age&amp;#125;// 原型对象上的属性Person.prototype.intro = function() &amp;#123;    console.log(`i am">
<meta property="og:locale" content="zh-CN">
<meta property="og:updated_time" content="2019-11-26T07:26:49.134Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="js-深入-new模拟实现">
<meta name="twitter:description" content="new 的模拟实现new 操作符的使用12345678910111213141516// 构造函数function Person(name, age) &amp;#123;    this.name = name    this.age = age&amp;#125;// 原型对象上的属性Person.prototype.intro = function() &amp;#123;    console.log(`i am">
    
        <link rel="alternate" type="application/atom+xml" title="lafen" href="/atom.xml">
    
    <link rel="shortcut icon" href="/img/favicon.ico">
    <link rel="stylesheet" href="//unpkg.com/hexo-theme-material-indigo@latest/css/style.css">
    <script>window.lazyScripts=[]</script>

    <!-- custom head -->
    

</head>

<body>
    <div id="loading" class="active"></div>

    <aside id="menu" class="hide">
  <div class="inner flex-row-vertical">
    <a href="javascript:;" class="header-icon waves-effect waves-circle waves-light" id="menu-off">
        <i class="icon icon-lg icon-close"></i>
    </a>
    <div class="brand-wrap" style="background-image:url(/img/brand.jpg)">
      <div class="brand">
        <a href="/" class="avatar waves-effect waves-circle waves-light">
          <img src="/img/avatar.jpg">
        </a>
        <hgroup class="introduce">
          <h5 class="nickname">lafen</h5>
          <a href="mailto:1031822863@qq.com" title="1031822863@qq.com" class="mail">1031822863@qq.com</a>
        </hgroup>
      </div>
    </div>
    <div class="scroll-wrap flex-col">
      <ul class="nav">
        
            <li class="waves-block waves-effect">
              <a href="/">
                <i class="icon icon-lg icon-home"></i>
                home
              </a>
            </li>
        
            <li class="waves-block waves-effect">
              <a href="/archives">
                <i class="icon icon-lg icon-archives"></i>
                Archives
              </a>
            </li>
        
            <li class="waves-block waves-effect">
              <a href="/tags">
                <i class="icon icon-lg icon-tags"></i>
                Tags
              </a>
            </li>
        
            <li class="waves-block waves-effect">
              <a href="/categories">
                <i class="icon icon-lg icon-th-list"></i>
                Categories
              </a>
            </li>
        
            <li class="waves-block waves-effect">
              <a href="https://github.com/zhongxiaotian" target="_blank">
                <i class="icon icon-lg icon-github"></i>
                Github
              </a>
            </li>
        
            <li class="waves-block waves-effect">
              <a href="http://www.weibo.com/" target="_blank">
                <i class="icon icon-lg icon-weibo"></i>
                Weibo
              </a>
            </li>
        
            <li class="waves-block waves-effect">
              <a href="https://gitee.com/lafen" target="_blank">
                <i class="icon icon-lg icon-link"></i>
                Gitee
              </a>
            </li>
        
      </ul>
    </div>
  </div>
</aside>

    <main id="main">
        <header class="top-header" id="header">
    <div class="flex-row">
        <a href="javascript:;" class="header-icon waves-effect waves-circle waves-light on" id="menu-toggle">
          <i class="icon icon-lg icon-navicon"></i>
        </a>
        <div class="flex-col header-title ellipsis">js-深入-new模拟实现</div>
        
        <div class="search-wrap" id="search-wrap">
            <a href="javascript:;" class="header-icon waves-effect waves-circle waves-light" id="back">
                <i class="icon icon-lg icon-chevron-left"></i>
            </a>
            <input type="text" id="key" class="search-input" autocomplete="off" placeholder="输入感兴趣的关键字">
            <a href="javascript:;" class="header-icon waves-effect waves-circle waves-light" id="search">
                <i class="icon icon-lg icon-search"></i>
            </a>
        </div>
        
        
        <a href="javascript:;" class="header-icon waves-effect waves-circle waves-light" id="menuShare">
            <i class="icon icon-lg icon-share-alt"></i>
        </a>
        
    </div>
</header>
<header class="content-header post-header">

    <div class="container fade-scale">
        <h1 class="title">js-深入-new模拟实现</h1>
        <h5 class="subtitle">
            
                <time datetime="2019-11-23T02:46:15.000Z" itemprop="datePublished" class="page-time">
  2019-11-23
</time>


	<ul class="article-category-list"><li class="article-category-list-item"><a class="article-category-list-link" href="/categories/js/">js</a><ul class="article-category-list-child"><li class="article-category-list-item"><a class="article-category-list-link" href="/categories/js/note/">note</a></li></ul></li></ul>

            
        </h5>
    </div>

    


</header>


<div class="container body-wrap">
    
    <aside class="post-widget">
        <nav class="post-toc-wrap post-toc-shrink" id="post-toc">
            <h4>TOC</h4>
            <ol class="post-toc"><li class="post-toc-item post-toc-level-4"><a class="post-toc-link" href="#new-的模拟实现"><span class="post-toc-number">1.</span> <span class="post-toc-text">new 的模拟实现</span></a><ol class="post-toc-child"><li class="post-toc-item post-toc-level-5"><a class="post-toc-link" href="#new-操作符的使用"><span class="post-toc-number">1.1.</span> <span class="post-toc-text">new 操作符的使用</span></a></li><li class="post-toc-item post-toc-level-5"><a class="post-toc-link" href="#new-模拟实现"><span class="post-toc-number">1.2.</span> <span class="post-toc-text">new 模拟实现</span></a></li><li class="post-toc-item post-toc-level-5"><a class="post-toc-link" href="#es6-简化版"><span class="post-toc-number">1.3.</span> <span class="post-toc-text">es6 简化版</span></a></li><li class="post-toc-item post-toc-level-5"><a class="post-toc-link" href="#参考："><span class="post-toc-number">1.4.</span> <span class="post-toc-text">参考：</span></a></li></ol></li></ol>
        </nav>
    </aside>


<article id="post-js-深入-new模拟实现/js-深入-new模拟实现" class="post-article article-type-post fade" itemprop="blogPost">

    <div class="post-card">
        <h1 class="post-card-title">js-深入-new模拟实现</h1>
        <div class="post-meta">
            <time class="post-time" title="2019-11-23 10:46:15" datetime="2019-11-23T02:46:15.000Z" itemprop="datePublished">2019-11-23</time>

            
	<ul class="article-category-list"><li class="article-category-list-item"><a class="article-category-list-link" href="/categories/js/">js</a><ul class="article-category-list-child"><li class="article-category-list-item"><a class="article-category-list-link" href="/categories/js/note/">note</a></li></ul></li></ul>



            
<span id="busuanzi_container_page_pv" title="文章总阅读量" style="display:none">
    <i class="icon icon-eye icon-pr"></i><span id="busuanzi_value_page_pv"></span>
</span>


        </div>
        <div class="post-content" id="post-content" itemprop="postContent">
            <h4 id="new-的模拟实现"><a href="#new-的模拟实现" class="headerlink" title="new 的模拟实现"></a>new 的模拟实现</h4><h5 id="new-操作符的使用"><a href="#new-操作符的使用" class="headerlink" title="new 操作符的使用"></a><code>new</code> 操作符的使用</h5><figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">// 构造函数</span></span><br><span class="line"><span class="function"><span class="keyword">function</span> <span class="title">Person</span>(<span class="params">name, age</span>) </span>&#123;</span><br><span class="line">    <span class="keyword">this</span>.name = name</span><br><span class="line">    <span class="keyword">this</span>.age = age</span><br><span class="line">&#125;</span><br><span class="line"><span class="comment">// 原型对象上的属性</span></span><br><span class="line">Person.prototype.intro = <span class="function"><span class="keyword">function</span>(<span class="params"></span>) </span>&#123;</span><br><span class="line">    <span class="built_in">console</span>.log(<span class="string">`i am <span class="subst">$&#123; <span class="keyword">this</span>.name &#125;</span>, i am <span class="subst">$&#123; <span class="keyword">this</span>.age &#125;</span> years old.`</span>)</span><br><span class="line">&#125;</span><br><span class="line"><span class="comment">// 创建实例</span></span><br><span class="line"><span class="keyword">var</span> somebody = <span class="keyword">new</span> Person(<span class="string">'Andy'</span>, <span class="number">18</span>)</span><br><span class="line"><span class="comment">// 属性</span></span><br><span class="line">somebody.name <span class="comment">// Andy</span></span><br><span class="line">somebody.age <span class="comment">// 18</span></span><br><span class="line"><span class="comment">// 调用原型上的方法</span></span><br><span class="line">somebody.intro() <span class="comment">// i am Andy, i am 18 years old.</span></span><br></pre></td></tr></table></figure>
<p><code>new</code> 操作符创建出来的实例，可以访问构造函数 <code>Person</code> 里的属性，也可以访问 <code>Person.prototype</code> 中的属性</p>
<p>使用 <code>new</code> 构造函数创建实例实际上会经历以下 <code>4</code> 个步骤</p>
<ol>
<li>创建一个<strong>新的对象</strong></li>
<li>将构造函数的作用域赋给新对象（因此 <strong><code>this</code> 指向了这个新对象</strong>）</li>
<li>执行构造函数中的代码（为这个<strong>新对象添加属性</strong>）</li>
<li><strong>返回新对象</strong></li>
</ol>
<p>那模拟 <code>new</code> 操作符，因为 <code>new</code> 是一个操作符，所以我们通过一个函数来模拟 <code>new</code> 操作符，即 </p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">var</span> somebody = <span class="keyword">new</span> Person(<span class="string">'Andy'</span>, <span class="number">18</span>) <span class="comment">// 使用 new</span></span><br><span class="line"><span class="keyword">var</span> somebody = objectFactory(Person, <span class="string">'Andy'</span>, <span class="number">18</span>) <span class="comment">// 使用 objectFactory</span></span><br></pre></td></tr></table></figure>
<h5 id="new-模拟实现"><a href="#new-模拟实现" class="headerlink" title="new 模拟实现"></a>new 模拟实现</h5><p>那就按照 <code>new</code> 操作符的步骤实现一下这个函数</p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br></pre></td><td class="code"><pre><span class="line"><span class="function"><span class="keyword">function</span> <span class="title">objectFatory</span>(<span class="params"></span>) </span>&#123;</span><br><span class="line">    <span class="comment">// 1. 创建一个新对象</span></span><br><span class="line">    <span class="keyword">var</span> obj = <span class="keyword">new</span> <span class="built_in">Object</span>()</span><br><span class="line">    <span class="comment">// 2. 利用 arguments 获得传入的构造器 Person，注意 shift 会改变原数组</span></span><br><span class="line">    <span class="keyword">var</span> Cons = <span class="built_in">Array</span>.prototype.shift.call(<span class="built_in">arguments</span>)</span><br><span class="line">    <span class="comment">// 3. 创建对象指向构造器原型对象的指针</span></span><br><span class="line">    obj.__proto__ = Cons.prototype</span><br><span class="line">    <span class="comment">// 4. 利用 apply 改变构造函数的 this 指向新对象 obj</span></span><br><span class="line">    Cons.apply(obj, <span class="built_in">arguments</span>)</span><br><span class="line">    <span class="comment">// 5. 返回新对象 obj</span></span><br><span class="line">    <span class="keyword">return</span> obj</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<p>测试，没毛病</p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">var</span> sb = objectFatory(Person, <span class="string">'Baby'</span>, <span class="number">22</span>)</span><br><span class="line">sb.name <span class="comment">// Baby</span></span><br><span class="line">sb.age <span class="comment">// 22</span></span><br><span class="line">sb.intro() <span class="comment">// i am Baby, i am 22 years old.</span></span><br></pre></td></tr></table></figure>
<p>但是，构造函数 <code>Person</code> 在未显式返回对象的时候是<strong>默认</strong>返回<strong>新创建的对象</strong>，但是其实是可以<strong>显式</strong>的返回对象的</p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">// 构造函数</span></span><br><span class="line"><span class="function"><span class="keyword">function</span> <span class="title">Person</span>(<span class="params">name, age</span>) </span>&#123;</span><br><span class="line">    <span class="keyword">this</span>.name = name</span><br><span class="line">    <span class="keyword">this</span>.age = age</span><br><span class="line">    <span class="comment">// 显式的返回一个对象</span></span><br><span class="line">    <span class="keyword">return</span> &#123;</span><br><span class="line">        name: name,</span><br><span class="line">        age: age</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="comment">// 或者说返回一个字符串</span></span><br><span class="line">    <span class="comment">// return 'abc'</span></span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<p>这种情况下 <code>objectFactory</code> 就不能直接返回创建新对象 <code>obj</code> 了，应该判断一下<strong>构造器</strong>中是否有显式的返回，如果返回一个对象，则这个对象返回，否则该返回什么就返回什么</p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br></pre></td><td class="code"><pre><span class="line"><span class="function"><span class="keyword">function</span> <span class="title">objectFatory</span>(<span class="params"></span>) </span>&#123;</span><br><span class="line">    <span class="comment">// 1. 创建一个新对象</span></span><br><span class="line">    <span class="keyword">var</span> obj = <span class="keyword">new</span> <span class="built_in">Object</span>()</span><br><span class="line">    <span class="comment">// 2. 利用 arguments 获得传入的构造器 Person，注意 shift 会改变原数组</span></span><br><span class="line">    <span class="keyword">var</span> Cons = <span class="built_in">Array</span>.prototype.shift.call(<span class="built_in">arguments</span>)</span><br><span class="line">    <span class="comment">// 3. 创建对象指向构造器原型对象的指针</span></span><br><span class="line">    obj.__proto__ = Cons.prototype</span><br><span class="line">    <span class="comment">// 4. 利用 apply 改变构造函数的 this 指向新对象 obj</span></span><br><span class="line">    <span class="keyword">var</span> res = Cons.apply(obj, <span class="built_in">arguments</span>)</span><br><span class="line">    <span class="comment">// 5. 返回新对象 obj 或构造器返回的数据 res</span></span><br><span class="line">    <span class="keyword">return</span> <span class="keyword">typeof</span> res === <span class="string">'object'</span> ? res : obj</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<h5 id="es6-简化版"><a href="#es6-简化版" class="headerlink" title="es6 简化版"></a><code>es6</code> 简化版</h5><p>利用剩余参数 <code>...</code> 与 <code>Object.create</code></p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"><span class="function"><span class="keyword">function</span> <span class="title">objectFactory</span>(<span class="params">Cons, ...rest</span>) </span>&#123;</span><br><span class="line">	<span class="keyword">let</span> obj = <span class="built_in">Object</span>.create(Cons.prototype)</span><br><span class="line">    <span class="keyword">let</span> res = Cons.apply(obj, rest)</span><br><span class="line">    <span class="keyword">return</span> (<span class="keyword">typeof</span> res === <span class="string">'object'</span> &amp;&amp; res) || obj</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<h5 id="参考："><a href="#参考：" class="headerlink" title="参考："></a>参考：</h5><p><a href="https://github.com/mqyqingfeng/Blog/issues/13" target="_blank" rel="noopener">JavaScript深入之new的模拟实现</a></p>

        </div>

        <blockquote class="post-copyright">
    
    <div class="content">
        
<span class="post-time">
    最后更新时间：<time datetime="2019-11-26T07:26:49.134Z" itemprop="dateUpdated">2019-11-26 15:26:49</time>
</span><br>


        
        关于学习类文章网上已经有非常多，而此处文章都是我在学习过程中整理摘录的笔记，参考文章可以点击文末的参考链接进行查阅
        
    </div>
    
    <footer>
        <a href="https://lafen.gitee.io">
            <img src="/img/avatar.jpg" alt="lafen">
            lafen
        </a>
    </footer>
</blockquote>

        
<div class="page-reward">
    <a id="rewardBtn" href="javascript:;" class="page-reward-btn waves-effect waves-circle waves-light">赏</a>
</div>



        <div class="post-footer">
            
	<ul class="article-tag-list"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/js/">js</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/note/">note</a></li></ul>


            
<div class="page-share-wrap">
    

<div class="page-share" id="pageShare">
    <ul class="reset share-icons">
      <li>
        <a class="weibo share-sns" target="_blank" href="http://service.weibo.com/share/share.php?url=https://lafen.gitee.io/2019/11/23/js-深入-new模拟实现/js-深入-new模拟实现/&title=《js-深入-new模拟实现》 — lafen&pic=https://lafen.gitee.io/img/avatar.jpg" data-title="微博">
          <i class="icon icon-weibo"></i>
        </a>
      </li>
      <li>
        <a class="weixin share-sns wxFab" href="javascript:;" data-title="微信">
          <i class="icon icon-weixin"></i>
        </a>
      </li>
      <li>
        <a class="qq share-sns" target="_blank" href="http://connect.qq.com/widget/shareqq/index.html?url=https://lafen.gitee.io/2019/11/23/js-深入-new模拟实现/js-深入-new模拟实现/&title=《js-深入-new模拟实现》 — lafen&source=lafen's personal blog" data-title=" QQ">
          <i class="icon icon-qq"></i>
        </a>
      </li>
      <li>
        <a class="facebook share-sns" target="_blank" href="https://www.facebook.com/sharer/sharer.php?u=https://lafen.gitee.io/2019/11/23/js-深入-new模拟实现/js-深入-new模拟实现/" data-title=" Facebook">
          <i class="icon icon-facebook"></i>
        </a>
      </li>
      <li>
        <a class="twitter share-sns" target="_blank" href="https://twitter.com/intent/tweet?text=《js-深入-new模拟实现》 — lafen&url=https://lafen.gitee.io/2019/11/23/js-深入-new模拟实现/js-深入-new模拟实现/&via=https://lafen.gitee.io" data-title=" Twitter">
          <i class="icon icon-twitter"></i>
        </a>
      </li>
      <li>
        <a class="google share-sns" target="_blank" href="https://plus.google.com/share?url=https://lafen.gitee.io/2019/11/23/js-深入-new模拟实现/js-深入-new模拟实现/" data-title=" Google+">
          <i class="icon icon-google-plus"></i>
        </a>
      </li>
    </ul>
 </div>



    <a href="javascript:;" id="shareFab" class="page-share-fab waves-effect waves-circle">
        <i class="icon icon-share-alt icon-lg"></i>
    </a>
</div>



        </div>
    </div>

    
<nav class="post-nav flex-row flex-justify-between">
  
    <div class="waves-block waves-effect prev">
      <a href="/2019/11/26/js-深入-promise模拟实现/js-深入-promise模拟实现/" id="post-prev" class="post-nav-link">
        <div class="tips"><i class="icon icon-angle-left icon-lg icon-pr"></i> Prev</div>
        <h4 class="title">js-深入-promise模拟实现</h4>
      </a>
    </div>
  

  
    <div class="waves-block waves-effect next">
      <a href="/2019/11/20/vue-项目记录/vue-项目记录/" id="post-next" class="post-nav-link">
        <div class="tips">Next <i class="icon icon-angle-right icon-lg icon-pl"></i></div>
        <h4 class="title">vue-项目记录</h4>
      </a>
    </div>
  
</nav>



    




















</article>

<div id="reward" class="page-modal reward-lay">
    <a class="close" href="javascript:;"><i class="icon icon-close"></i></a>
    <h3 class="reward-title">
        <i class="icon icon-quote-left"></i>
        打笔巨款？~
        <i class="icon icon-quote-right"></i>
    </h3>
    <div class="reward-content">
        
        <div class="reward-code">
            <img id="rewardCode" src="/img/wechat.jpg" alt="打赏二维码">
        </div>
        
        <label class="reward-toggle">
            <input id="rewardToggle" type="checkbox" class="reward-toggle-check" data-wechat="/img/wechat.jpg" data-alipay="/img/alipay.jpg">
            <div class="reward-toggle-ctrol">
                <span class="reward-toggle-item wechat">微信</span>
                <span class="reward-toggle-label"></span>
                <span class="reward-toggle-item alipay">支付宝</span>
            </div>
        </label>
        
    </div>
</div>



</div>

        <footer class="footer">
    <div class="top">
        
<p>
    <span id="busuanzi_container_site_uv" style="display:none">
        站点总访客数：<span id="busuanzi_value_site_uv"></span>
    </span>
    <span id="busuanzi_container_site_pv" style="display:none">
        站点总访问量：<span id="busuanzi_value_site_pv"></span>
    </span>
</p>


        <p>
            
                <span><a href="/atom.xml" target="_blank" class="rss" title="rss"><i class="icon icon-lg icon-rss"></i></a></span>
            
            <span>博客内容遵循 <a rel="license" href="https://creativecommons.org/licenses/by-nc-sa/4.0/deed.zh">知识共享 署名 - 非商业性 - 相同方式共享 4.0 国际协议</a></span>
        </p>
    </div>
    <div class="bottom">
        <p><span>lafen &copy; 2019 - 2020</span>
            <span>
                
                Power by <a href="http://hexo.io/" target="_blank">Hexo</a> Theme <a href="https://github.com/yscoder/hexo-theme-indigo" target="_blank">indigo</a>
            </span>
        </p>
    </div>
</footer>

    </main>
    <div class="mask" id="mask"></div>
<a href="javascript:;" id="gotop" class="waves-effect waves-circle waves-light"><span class="icon icon-lg icon-chevron-up"></span></a>



<div class="global-share" id="globalShare">
    <ul class="reset share-icons">
      <li>
        <a class="weibo share-sns" target="_blank" href="http://service.weibo.com/share/share.php?url=https://lafen.gitee.io/2019/11/23/js-深入-new模拟实现/js-深入-new模拟实现/&title=《js-深入-new模拟实现》 — lafen&pic=https://lafen.gitee.io/img/avatar.jpg" data-title="微博">
          <i class="icon icon-weibo"></i>
        </a>
      </li>
      <li>
        <a class="weixin share-sns wxFab" href="javascript:;" data-title="微信">
          <i class="icon icon-weixin"></i>
        </a>
      </li>
      <li>
        <a class="qq share-sns" target="_blank" href="http://connect.qq.com/widget/shareqq/index.html?url=https://lafen.gitee.io/2019/11/23/js-深入-new模拟实现/js-深入-new模拟实现/&title=《js-深入-new模拟实现》 — lafen&source=lafen's personal blog" data-title=" QQ">
          <i class="icon icon-qq"></i>
        </a>
      </li>
      <li>
        <a class="facebook share-sns" target="_blank" href="https://www.facebook.com/sharer/sharer.php?u=https://lafen.gitee.io/2019/11/23/js-深入-new模拟实现/js-深入-new模拟实现/" data-title=" Facebook">
          <i class="icon icon-facebook"></i>
        </a>
      </li>
      <li>
        <a class="twitter share-sns" target="_blank" href="https://twitter.com/intent/tweet?text=《js-深入-new模拟实现》 — lafen&url=https://lafen.gitee.io/2019/11/23/js-深入-new模拟实现/js-深入-new模拟实现/&via=https://lafen.gitee.io" data-title=" Twitter">
          <i class="icon icon-twitter"></i>
        </a>
      </li>
      <li>
        <a class="google share-sns" target="_blank" href="https://plus.google.com/share?url=https://lafen.gitee.io/2019/11/23/js-深入-new模拟实现/js-深入-new模拟实现/" data-title=" Google+">
          <i class="icon icon-google-plus"></i>
        </a>
      </li>
    </ul>
 </div>


<div class="page-modal wx-share" id="wxShare">
    <a class="close" href="javascript:;"><i class="icon icon-close"></i></a>
    <p>扫一扫，分享到微信</p>
    <img src="" alt="微信分享二维码">
</div>




    <script src="//cdn.bootcss.com/node-waves/0.7.4/waves.min.js"></script>
<script>
var BLOG = { ROOT: '/', SHARE: true, REWARD: true };


</script>

<script src="//unpkg.com/hexo-theme-material-indigo@latest/js/main.min.js"></script>


<div class="search-panel" id="search-panel">
    <ul class="search-result" id="search-result"></ul>
</div>
<template id="search-tpl">
<li class="item">
    <a href="{path}" class="waves-block waves-effect">
        <div class="title ellipsis" title="{title}">{title}</div>
        <div class="flex-row flex-middle">
            <div class="tags ellipsis">
                {tags}
            </div>
            <time class="flex-col time">{date}</time>
        </div>
    </a>
</li>
</template>

<script src="//unpkg.com/hexo-theme-material-indigo@latest/js/search.min.js" async></script>






<script async src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script>



<script>
(function() {
    var OriginTitile = document.title, titleTime;
    document.addEventListener('visibilitychange', function() {
        if (document.hidden) {
            document.title = '死鬼去哪里了！';
            clearTimeout(titleTime);
        } else {
            document.title = '(つェ⊂)咦!又好了!';
            titleTime = setTimeout(function() {
                document.title = OriginTitile;
            },2000);
        }
    });
})();
</script>



<script src="/live2dw/lib/L2Dwidget.min.js?094cbace49a39548bed64abff5988b05"></script><script>L2Dwidget.init({"pluginRootPath":"live2dw/","pluginJsPath":"lib/","pluginModelPath":"assets/","tagMode":false,"debug":false,"model":{"scale":1,"jsonPath":"/live2dw/assets/shizuku.model.json"},"display":{"positon":"right","width":150,"height":300},"mobile":{"show":true,"scale":0.8},"react":{"opacity":0.8,"opacityDefault":0.8,"opacityOnHover":0.6},"log":false});</script></body>
</html>
